package Tool;

import java.util.ArrayList;
import java.util.Random;

public class VerificationCode {
    public static String getCode() {
        ArrayList<Character> list=new ArrayList<>();
        for (int i = 0; i < 26; i++) {
            list.add((char)('a' + i));//a - z
            list.add((char)('A' + i));//A - Z
        }
        Random r=new Random();
        StringBuilder sb=new StringBuilder();
        for (int i = 0; i < 4; i++) {
            int index=r.nextInt(list.size());
            Character c = list.get(index);
            sb.append(c);
        }
        int num= r.nextInt(10);
        char[]arr=sb.append(num).toString().toCharArray();
        int index= r.nextInt(arr.length);
        char temp = arr[arr.length - 1];
        arr[arr.length-1]=arr[index];
        arr[index]=temp;
        return new String(arr);

    }
}
